package com.cnpc.framework.base.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import com.cnpc.framework.base.entity.BaseResponse;
import com.cnpc.framework.base.service.UserService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class MainController {

    Logger logger = Logger.getLogger(MainController.class);
    @Resource
    private UserService us;
    @RequestMapping(method = RequestMethod.GET, value = "/")
    public String index(HttpServletRequest request) {
        //首页加载邮件消息 message/count  user/getAvatar

        return "main";
    }

    @RequestMapping(method = RequestMethod.GET, value = "/main")
    public String main(HttpServletRequest request) {

        return "main";
    }

    @RequestMapping(method = RequestMethod.GET, value = "/homePage")
    public String homePage(HttpServletRequest request) {

        return "homePage";
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/user/changePassword")
    public BaseResponse changePassword(String loginName, String password) {
        BaseResponse result = null;

        try {

            result = us.updatePassword(loginName, password);

        } catch (Exception e) {
            e.printStackTrace();
            result = new BaseResponse();
            result.setStatus(1);
            result.setMessage("系统内部错误！");
        }
        return result;
    }





}
